package edu.zut.cs.software.perfect.attendance.service.impl;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.zut.cs.software.perfect.attendance.dao.AttendanceClerkDao;
import edu.zut.cs.software.perfect.attendance.domain.AttendanceClerk;
import edu.zut.cs.software.perfect.attendance.service.AttendanceClerkManager;
import edu.zut.cs.software.perfect.base.service.impl.GenericTreeManagerImpl;

/**
 * 
 * @Title: AttendanceClerkManagerImpl
 * @Description: TODO
 * @author: lipengde
 * @date 2020年5月30日 下午4:09:39
 */
@Service(value = "attendanceClerkManager")
public class AttendanceClerkManagerImpl extends GenericTreeManagerImpl<AttendanceClerk, Long>
		implements AttendanceClerkManager {

	AttendanceClerkDao attendanceClerkDao;

	@Autowired
	public void setAttendanceClerkDao(AttendanceClerkDao attendanceClerkDao) {
		this.attendanceClerkDao = attendanceClerkDao;
		this.treeDao=attendanceClerkDao;
		this.dao = attendanceClerkDao;
	}

	@Override
	public List<AttendanceClerk> findAll(){
		return (List<AttendanceClerk>)this.dao.findAll();
	}
	
	@Override
	public Optional<AttendanceClerk> findByCourseId(Long courseId) {
		// TODO Auto-generated method stub
		Optional<AttendanceClerk> result = this.dao.findById(courseId);
		return result;
	}

	@Override
	public Boolean deleteById(Long courseId) {
		// TODO Auto-generated method stub
		Optional<AttendanceClerk> attendanceclerk = this.dao.findById(courseId);
		if(attendanceclerk.equals(Optional.empty())) {
			return false;
		}else {
			this.dao.delete(attendanceclerk.get());
			return true;
		}
	}

}
